package com.trhui.mallbook.client;

import com.trhui.mallbook.domain.common.ApiRequest;
import com.trhui.mallbook.domain.common.BaseResponse;
import com.trhui.mallbook.domain.request.dg.DgWxConfigQueryRequest;
import com.trhui.mallbook.domain.request.dg.DgWxConfigRequest;
import com.trhui.mallbook.domain.request.yb.YbWxConfigQueryRequest;
import com.trhui.mallbook.domain.request.yb.YbWxConfigRequest;
import com.trhui.mallbook.domain.response.dg.DgWxConfigQueryResponse;
import com.trhui.mallbook.domain.response.dg.DgWxConfigResponse;
import com.trhui.mallbook.domain.response.yb.YbQueryWxConfigResponse;
import com.trhui.mallbook.domain.response.yb.YbWxConfigResponse;
import com.trhui.mallbook.enums.ChannelTypeEnum;
import com.trhui.mallbook.enums.ServerCodeEnum;

/**
 * 公众号配置接口
 *
 * @author linjy
 */
public class WxConfigClient extends AbstractClient {

    /**
     * 易宝公众号配置接口
     *
     * @param request
     * @return
     */
    public static BaseResponse<YbWxConfigResponse> ybWxConfig(YbWxConfigRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.WX_CONFIG)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(apiRequest, YbWxConfigResponse.class);
    }

    /**
     * 易宝公众号配置查询接口
     *
     * @param request
     * @return
     */
    public static BaseResponse<YbQueryWxConfigResponse> ybWxConfigQuery(YbWxConfigQueryRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.QUERY_WX_CONFIG)
                .channelType(ChannelTypeEnum.YB)
                .build();
        return post(apiRequest, YbQueryWxConfigResponse.class);
    }

    /**
     * 斗拱公众号配置接口
     * @param request
     * @return
     */
    public static BaseResponse<DgWxConfigResponse> dgWxConfig(DgWxConfigRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.DG_WX_CONFIG)
                .channelType(ChannelTypeEnum.DG)
                .build();
        return post(apiRequest, DgWxConfigResponse.class);
    }

    /**
     * 斗拱公众号配置查询接口
     * @param request
     * @return
     */
    public static BaseResponse<DgWxConfigQueryResponse> dgWxConfigQuery(DgWxConfigQueryRequest request) {
        ApiRequest apiRequest = new ApiRequest.ApiRequestBuild()
                .merOrderId(request.getMerOrderId())
                .merchantNo(request.getMerchantNo())
                .params(request)
                .serverCode(ServerCodeEnum.DG_WX_CONFIG_QUERY)
                .channelType(ChannelTypeEnum.DG)
                .build();
        return post(apiRequest, DgWxConfigQueryResponse.class);
    }
}
